package store.Service;

import store.Index;
import store.control.UserService;
import store.entry.User;

import java.util.ArrayList;
import java.util.Scanner;

public class SelfInfomation {
    public static ArrayList<User> infoArr = new ArrayList<>();

    //显示个人信息
    public static void Infomation() {
        System.out.println("您的个人信息如下");
        for (User user : infoArr) {
            System.out.println("用户名\t昵称\t年龄");
            System.out.println(user.getUsername() + "\t" + user.getOtherName() + "\t" + user.getAge());
        }
    }
    //注销登录
    public static void CancelLogin(){
        System.out.println("您确定要注销当前账号吗？\t"+infoArr.get(0).getOtherName()+"\t(是Y 否任意键)");
        String choice = new Scanner(System.in).next();
        if (choice.equals("Y")){
            for (int i = 0; i < UserService.userArr.size(); i++) {
                if (UserService.userArr.get(i).getUsername().equals(infoArr.get(0).getUsername())){

                    UserService.userArr.remove(i);
                    break;
                }
            }
            System.out.println("注销成功");
            BuyCar.buyCarArr.clear();//清空购物车
            SelfInfomation.infoArr.clear();//清空个人信息
            Index.Index();
        }

    }
}
